﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Diagnostics;

namespace CashFlow.Web
{
	public class HandleWebErrorAttribute : HandleErrorAttribute
	{
		public override void OnException(ExceptionContext filterContext)
		{
			filterContext.ExceptionHandled = false;
			filterContext.HttpContext.Response.StatusCode = 200;

			var actionName = (string)filterContext.RouteData.Values["action"];
			var controllerName = filterContext.Controller.GetType().Name;
			Trace.TraceError(
				"TR0000000002. ERROR. Controller: {0}; Action: {1}; Exception: {2}", 
				controllerName,
				actionName,
				filterContext.Exception);

			base.OnException(filterContext);
		}
	}
}